package com.yzq.enums;

import lombok.Getter;

/**
 * 验证码状态枚举类 'unused','used','expired'
 */
@Getter
public enum VerificationCodeStatus {
    UNUSED("unused","未使用"),
    USED("used","已使用"),
    EXPIRED("expired","已过期");
    private final String code;
    private final String message;
    VerificationCodeStatus(String code, String message) {
        this.code = code;
        this.message = message;
    }

    /**
     * 根据code获取枚举
     * @param code 枚举code
     * @return 枚举
     */
    public static VerificationCodeStatus getByCode(String code) {
        for (VerificationCodeStatus value : values()) {
            if (value.code.equals(code)) {
                return value;
            }
        }
        return null;
    }

}
